package com.ytjj.qmyx.admin.service.impl;

import com.ytjj.qmyx.admin.dao.ProductSpecialDao;
import com.ytjj.qmyx.admin.model.request.SpecialProductRequest;
import com.ytjj.qmyx.admin.service.ProductSpecialService;
import com.ytjj.qmyx.mall.model.ProductSpecial;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 
 * 
 * @Version: 1.0
 */
@Service
public class ProductSpecialServiceImpl implements ProductSpecialService {

	@Resource
	private ProductSpecialDao productSpecialDao;

	@Override
	public void batchProductSpecial(SpecialProductRequest request) {
		// 获取商品id集合
		Integer[] ids = request.getProductIds();
		if(ids.length > 0) {
			for(Integer id : ids) {
				ProductSpecial specialPro = new ProductSpecial();
				specialPro.setProductId(id);
				specialPro.setSpecialId(request.getSpecialId());
				specialPro.setType(request.getType());
				specialPro.setRecommendFlag(0);
				specialPro.setSort(1);
				specialPro.setStatus((byte) 2);
				//批量新增商品到专区表
				productSpecialDao.batchSpecialProduct(specialPro);
				//修改商品专区id
				productSpecialDao.batchUpProductSpecialId(id,request.getSpecialId());
			}
		}
	}
}
